package com.jerkin.executor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

/**
 * @version V1.0
 * @ClassName: ExeCutoreConsumerService
 * @Description:
 * @author: huhongzhi
 * @date: 2021/6/20 23:22
 */
public class ExecutoreConsumerService {

    private static ExecutorService executorService;

    public static ExecutorService get() {
        if (executorService == null) {
            synchronized (ExecutoreConsumerService.class) {
                if (executorService == null) {
                    executorService = Executors.newFixedThreadPool(10, new ThreadFactory() {
                        @Override
                        public Thread newThread(Runnable r) {
                            Thread thread = new Thread(r, "rpc-consumer-");
                            return thread;
                        }
                    });
                }
            }
        }
        return executorService;
    }
}
